<form id="pagerForm" method="post" action="">
	<input type="hidden" name="pageNum" value="{$pageNum}" />
	<input type="hidden" name="numPerPage" value="{$numPerPage}" />
</form>
<style>
    .suppliers {
        height: auto;
        overflow: hidden;
    }
	.suppliers dl{height: auto;overflow: hidden; clear:both;width:auto;}
	.suppliers dl dt{float:left;}
	.suppliers dl dd{float:left;}
</style>
<h2 class="contentTitle">查看订单询价</h2>
<div class="pageHeader">
    <div class="searchBar">
        <ul class="searchContent">
            <div class="buttonActive">
                <div class="buttonContent">
                    <button type="button" onclick="navTab.reload();">
                        刷新
                    </button>
                </div>
            </div>
            <div class="buttonActive">
                <div class="buttonContent">
                    <button type="button" onclick="navTab.closeCurrentTab();">
                        关闭
                    </button>
                </div>
            </div>
        </ul>
    </div>
</div>
<div class="pageContent">
    <div class="pageFormContent" layouth="136">
        <div id="w_list_print">
            <table class="list" width="100%" targetType="navTab">
                <thead>
                <tr>
                    <th>ID</th>
                    <th>名称/编码</th>
                    <th>单价</th>
                    <th>数量</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <volist name="list" id="vo">
                <volist name="vo" id="v">
                <tr>
                    <td>{$v['id']}</td>
                    <td>{$v['product_name']}
                        <br/>
                        {$v['product_psn']}
                    </td>
                    <td>{$v['price']/100|number_format=###,2,'.',''}</td>
                    <td>{$v['number']}</td>
                    <td><a class="button" href="javascript:oos({$v['order_id']},{$v['id']},{$pgptemp['id']},0,{$pgptemp['s_id']},this);"><span>缺货</span></a>
							<a class="button" href="javascript:oosbak({$v['order_id']},{$v['id']},{$isoknum});"><span>退款申请</span></a></td>
                </tr>
                <tr>
                    <td class="suppliers" colspan="5">
                        <dl>
                            <dt id="suppliers_{$v['id']}">{$pgp[$v['product_id']]['s_name']}</dt>
                            <dd><input type="text" class="autoinput" style="width:50px;" name="num" rel="{$v['order_id']}_{$v['id']}" id="{$v['order_id']}_{$v['id']}_num" value="{$v['number']}">
                                <php>
                                $pgptemp=$pgp[$v['product_id']];
                                $pprice=num2price($pgptemp,$v['number']);
                                $ospstr='';
                                $isoknum=0;
                                if($osp[$v['id']]){
                                $osptemp=$osp[$v['id']];
                                foreach($osptemp as $vs){
                                if($vs['status']==1){
                                $ospstr.=number_format($vs['buy_price']/100,2,'.','').'/'.$vs['num'].' 确认
                                <br>
                                ';
                                $isoknum+=$vs['num'];
                                }else{
                                $ospstr.=number_format($vs['buy_price']/100,2,'.','').'/'.$vs['num'].' 无效
                                <br>
                                ';
                                }
                                }
                                }
                                $isoknum=$v['number']-$isoknum;
                                </php>
                                <input type="hidden" name="sid" id="{$v['order_id']}_{$v['id']}_sid" value="{$pgptemp['s_id']}"><input type="text" class="autoinput" style="width:50px; margin:0 5px;" name="price" id="{$v['order_id']}_{$v['id']}_price" rel="{$v['order_id']}_{$v['id']}" value="{$pprice/100|number_format=###,2,'.',''}">
								<a class="button" href="javascript:oos({$v['order_id']},{$v['id']},{$pgptemp['id']},1,{$pgptemp['s_id']},this);"><span>有货</span></a></dd>
                            <dd>
                            <input type="text" class="autoinput" style="width:50px; margin:0 5px;" name="oosnum_{$v['id']}" id="{$v['order_id']}_{$v['id']}_oosnum" rel="{$v['order_id']}_{$v['id']}" value="{$isoknum}">
							</dd>
                            <dd id="{$v['order_id']}_{$v['id']}_status">{$ospstr}</dd>
                            </tr>
                        </dl>
                    </td>
                </tr>
                </volist>
                </volist>
                </tbody>
            </table>
        </div>
    </div>
    <div class="formBar">
        <ul>
            <li>
                <div class="buttonActive">
                    <div class="buttonContent">
                        <button type="submit">
                            完成
                        </button>
                    </div>
                </div>
            </li>
            <li>
                <div class="button">
                    <div class="buttonContent">
                        <button type="button" class"close">
 关闭
                        </button>
                    </div>
                </div>
            </li>
        </ul>
    </div>
</div>
<script>
    function oos(oid, gid, pid, status, sid, obj){
        var numid = oid + '_' + gid + '_num';
        var oosnumid = oid + '_' + gid + '_oosnum';
        var priceid = oid + '_' + gid + '_price';
        var statusstr = oid + '_' + gid + '_status';
        var num = $('#' + numid).val();
        var oosnum = $('#' + oosnumid).val();
        if (status == 0) {
            num = oosnum;
        }
        var price = $('#' + priceid).val();
        var datas = {
            oid: oid,
            gid: gid,
            pid: pid,
            status: status,
            sid: sid,
            num: num,
            price: price
        };
        var url = "{:U('Order/do_suppliers')}";
        $.ajax({
            type: "POST",
            url: url,
            data: datas,
            timeout: '3000',
            dataType: 'json',
            success: function(res){
                if (res.status != 200) {
                    alert(res.msg);
                }
                else {
                    $('#' + statusstr).html(res.msg);
                }
            }
        });
    }
</script>
